/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Damian
 */
@Entity
@Table(name = "offer_hourly")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OfferHourly.findAll", query = "SELECT o FROM OfferHourly o"),
    @NamedQuery(name = "OfferHourly.findByIdOfferHourly", query = "SELECT o FROM OfferHourly o WHERE o.offerHourlyPK.idOfferHourly = :idOfferHourly"),
    @NamedQuery(name = "OfferHourly.findByIdOffer", query = "SELECT o FROM OfferHourly o WHERE o.offerHourlyPK.idOffer = :idOffer"),
    @NamedQuery(name = "OfferHourly.findByIdHourly", query = "SELECT o FROM OfferHourly o WHERE o.offerHourlyPK.idHourly = :idHourly")})
public class OfferHourly implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OfferHourlyPK offerHourlyPK;
    @JoinColumn(name = "ID_OFFER", referencedColumnName = "ID_OFFER", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Offer offer;
    @JoinColumn(name = "ID_HOURLY", referencedColumnName = "ID_HOURLY_OFFER", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private HourlyOffer hourlyOffer;

    public OfferHourly() {
    }

    public OfferHourly(OfferHourlyPK offerHourlyPK) {
        this.offerHourlyPK = offerHourlyPK;
    }

    public OfferHourly(int idOfferHourly, int idOffer, int idHourly) {
        this.offerHourlyPK = new OfferHourlyPK(idOfferHourly, idOffer, idHourly);
    }

    public OfferHourlyPK getOfferHourlyPK() {
        return offerHourlyPK;
    }

    public void setOfferHourlyPK(OfferHourlyPK offerHourlyPK) {
        this.offerHourlyPK = offerHourlyPK;
    }

    public Offer getOffer() {
        return offer;
    }

    public void setOffer(Offer offer) {
        this.offer = offer;
    }

    public HourlyOffer getHourlyOffer() {
        return hourlyOffer;
    }

    public void setHourlyOffer(HourlyOffer hourlyOffer) {
        this.hourlyOffer = hourlyOffer;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (offerHourlyPK != null ? offerHourlyPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OfferHourly)) {
            return false;
        }
        OfferHourly other = (OfferHourly) object;
        if ((this.offerHourlyPK == null && other.offerHourlyPK != null) || (this.offerHourlyPK != null && !this.offerHourlyPK.equals(other.offerHourlyPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.OfferHourly[ offerHourlyPK=" + offerHourlyPK + " ]";
    }
    
}
